using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using ProductInterfaces;
using ProductBC;

namespace ProductWin32
{
    public partial class ProductForm : Form
    {
        public ProductForm()
        {
            InitializeComponent();
        }

        private ICategory __objCat = null;
        private void LoadCategories()
        {
            this.__objCat = CategoryManager.CreateCategory();
            this.cboCategories.DataSource = this.__objCat.ReadAll();   
        }

        private void ProductForm_Load(object sender, EventArgs e)
        {
            this.LoadCategories(); 
        }

        private IProduct __prod = null; 
        private void cboCategories_SelectedIndexChanged(object sender, EventArgs e)
        {
            this.__objCat.CategoryID = 
                int.Parse(this.cboCategories.SelectedValue.ToString());   
             this.__prod = this.__objCat.GetProduct();
             this.dataGridView1.DataSource =  this.__prod.Read(); 
        }
    }
}